package main

import (
	"game/src/logic"
	"game/src/logic/processor"
	"time"
)

// DoConnectionBegin 创建连接的时候执行
//func DoConnectionBegin(conn zInterface.IConnection) {
//	fmt.Println("DoConnecionBegin is Called ... ")
//
//	//=============设置两个链接属性，在连接创建之后===========
//	fmt.Println("Set conn Name, Home done!")
//	conn.SetProperty("Name", "Aceld")
//	conn.SetProperty("Home", "https://www.jianshu.com/u/35261429b7f1")
//	//===================================================
//
//	err := conn.SendMsg(2, []byte("DoConnection BEGIN..."))
//	if err != nil {
//		fmt.Println(err)
//	}
//}

// DoConnectionLost 连接断开的时候执行
//func DoConnectionLost(conn zInterface.IConnection) {
//	//============在连接销毁之前，查询conn的Name，Home属性=====
//	if name, err := conn.GetProperty("Name"); err == nil {
//		fmt.Println("Conn Property Name = ", name)
//	}
//
//	if home, err := conn.GetProperty("Home"); err == nil {
//		fmt.Println("Conn Property Home = ", home)
//	}
//	//===================================================
//
//	fmt.Println("DoConneciotnLost is Called ... ")
//}
func main() {
	//创建一个server句柄
	logic.NewServer()
	// 初始化manager
	logic.Ds = logic.NewDataStore()
	logic.InitItemPro()

	//配置路由
	logic.GameServer.AddRouter(1, &processor.LoginRouter{})
	logic.GameServer.AddRouter(11, &processor.CreatAliRouter{})
	logic.GameServer.AddRouter(12, &processor.WhichAliRouter{})
	logic.GameServer.AddRouter(13, &processor.AllAliRouter{})
	logic.GameServer.AddRouter(14, &processor.JoinAliRouter{})
	logic.GameServer.AddRouter(15, &processor.DismissAliRouter{})

	logic.GameServer.AddRouter(21, &processor.IncreaseCapacityRouter{})
	logic.GameServer.AddRouter(22, &processor.StoreCapacityRouter{})
	logic.GameServer.AddRouter(23, &processor.DestroyItemCapacityRouter{})
	logic.GameServer.AddRouter(24, &processor.ClearUpCapacityRouter{})

	//开启服务
	logic.GameServer.Start()
	for {
		time.Sleep(10 * time.Second)
	}
}
